<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<style type="text/css">
			body {
				background: #f1f1f1;
			}
		</style>
		<script src="https://checkout.airwallex.com/assets/elements.bundle.min.js"></script>
	</head>
	<body>
		<script type="text/javascript">
			function getQueryParams(url) {
				if (!url) return {};
				// 移除URL中的协议头（如http://）以及域名
				let queryString = url.split('?')[1];
				if (!queryString) return {};

				let queryParams = {};
				// 分割查询字符串并处理每个键值对
				queryString.split('&').forEach(function(pair) {
					let [key, value] = pair.split('=');
					// 解码键和值
					queryParams[decodeURIComponent(key)] = decodeURIComponent(value || '');
				});

				return queryParams;
			}
			var params = getQueryParams(window.location.href);
			Airwallex.init({
				env: 'demo',
				origin: window.location.origin
			});
			function redirectHppForCheckout(client_secret, intent_id) {
				Airwallex.redirectToCheckout({
					env: 'demo', // Which env('staging' | 'demo' | 'prod') you would like to integrate with
					mode: 'payment',
					intent_id: intent_id,
					client_secret: client_secret,
					currency: 'USD',
					successUrl: '', // 支付成功后跳转页面，必须是HTTPS
					failUrl: '', // 支付失败后跳转页面，必须是HTTPS
					logoUrl: '', //商户logo展示，必须是HTTPS
					locale: 'en' //前端语言设置，目前支持en, zh, ja, ko, ar, es, de, fr, it, nl
				});
			}
			redirectHppForCheckout(params.secretId, params.intentId);
		</script>
	</body>
</html>